﻿<?php
require_once './lib.php';
header("Content-type:text/html;charset=utf-8");
$mysql = new DBAccess();

//将数据表查询的最新一期期号放入数组
$arr = array();

//重庆时时彩最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_cq WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['CQ'] = $result;

//北京PK拾最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8,ball_9,ball_10 from lottery_result_bjpk WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['BJPK'] = $result;

//排列3最新期号
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_p3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['P3'] = $result;

//福彩3D最新期号
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_d3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['D3'] = $result;

//广东11选5最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_gd11 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GD11'] = $result;

//天津时时彩最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_tj WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['TJ'] = $result;

//广东快乐十分
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8 from lottery_result_gdsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GDSF'] = $result;

//天津快乐十分
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8 from lottery_result_tjsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['TJSF'] = $result;

//北京快乐八
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8,ball_9,ball_10,ball_11,ball_12,ball_13,ball_14,ball_15,ball_16,ball_17,ball_18,ball_19,ball_20 from lottery_result_bjkn WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['BJKN'] = $result;

//广西十分彩
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_gxsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GXSF'] = $result;

//上海时时乐  江苏快三
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_t3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['T3'] = $result;



//定义相关数组
$dx = array('大', '小');
$ds = array('单', '双');
$lh = array('龙', '虎', '和');
$num = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
$hsds = array('合数单', '合数双');
$wsdx = array('尾大', '尾小');
$dnxb = array('东', '南', '西', '北');
$zfb = array('中', '发', '白');
$zhdx = array('总和大', '总和小');
//$sql = "update order_lottery_sub set status=0,is_win=''";
//$sql1 = "update order_lottery set status=0";
//$mysql->query($sql);
//$mysql->query($sql1);
//exit();
//存在重庆时时彩最新一期未结算
if (!empty($arr['CQ'])) {
    var_dump($arr['CQ']);
    //对开奖结果进行换算规则
    $niuniu = b5_niuniu($arr['CQ']['ball_1'], $arr['CQ']['ball_2'], $arr['CQ']['ball_3'], $arr['CQ']['ball_4'], $arr['CQ']['ball_5']);
    $qishu_cq = $arr['CQ']['qishu'];
    //$hm存放球号
    $hm[] = $arr['CQ']['ball_1'];//第一个球
    $hm[] = $arr['CQ']['ball_2'];//第二个球
    $hm[] = $arr['CQ']['ball_3'];//第三个球
    $hm[] = $arr['CQ']['ball_4'];//第四个球
    $hm[] = $arr['CQ']['ball_5'];//第五个球
    //$hms存放规则
    $hms['zhs'][] = Ssc_Auto($hm, 1);//算总和
    $hms['zh'][] = Ssc_Auto($hm, 2);//算总和大小
    $hms['zh'][] = Ssc_Auto($hm, 3);//算总和单双
    $hms['zh'][] = Ssc_Auto($hm, 4);//算龙虎和
    $hms['three'][] = Ssc_Auto($hm, 5);//算前三
    $hms['three'][] = Ssc_Auto($hm, 6);//算中三
    $hms['three'][] = Ssc_Auto($hm, 7);//算后三
    $hms['niuniu'][] = $niuniu;//牛牛
    $hms['niuniu'][] = b5_niuds($niuniu);//牛大
    $hms['niuniu'][] = b5_niudx($niuniu);//牛小
    //var_dump($hms);
    //var_dump($hm);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_cq AND Gtype='CQ') AND status=0";
    $res = $mysql->getRows($sql);
    //var_dump($res);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[0]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], $hms['zh'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms['three'][0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms['three'][1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms['three'][2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "牛牛") {
            if (in_array($v['number'], $hms['niuniu'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
//函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

//判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
//将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

//将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_cq";
    $mysql->query($sql);

//将时时彩结果表状态修改为正常
    $sql = "update lottery_result_cq set state='1' WHERE state='0' AND qishu=$qishu_cq";
    $mysql->query($sql);

}

//存在北京PK拾最新一期未结算
if (!empty($arr['BJPK'])) {//北京PK
    var_dump($arr['BJPK']);
    $qishu_bjpk = $arr['BJPK']['qishu'];
    $hm1[] = $arr['BJPK']['ball_1'];
    $hm1[] = $arr['BJPK']['ball_2'];
    $hm1[] = $arr['BJPK']['ball_3'];
    $hm1[] = $arr['BJPK']['ball_4'];
    $hm1[] = $arr['BJPK']['ball_5'];
    $hm1[] = $arr['BJPK']['ball_6'];
    $hm1[] = $arr['BJPK']['ball_7'];
    $hm1[] = $arr['BJPK']['ball_8'];
    $hm1[] = $arr['BJPK']['ball_9'];
    $hm1[] = $arr['BJPK']['ball_10'];
    $hms1[] = Pk10_Auto_quick($hm1, 1);
    $hms1[] = Pk10_Auto_quick($hm1, 2);
    $hms1[] = Pk10_Auto_quick($hm1, 3);
    $hms1[] = Pk10_Auto_quick($hm1, 4);
    $hms1[] = Pk10_Auto_quick($hm1, 5);
    $hms1[] = Pk10_Auto_quick($hm1, 6);
    $hms1[] = Pk10_Auto_quick($hm1, 7);
    $hms1[] = Pk10_Auto_quick($hm1, 8);

    // var_dump($hm1);
    // var_dump($hms1);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_bjpk AND Gtype='BJPK') AND status=0";
    $res1 = $mysql->getRows($sql);
    //var_dump($res1);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res1 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "冠亚军和") {
            if ($v['number'] == $hms1[0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == $hms1[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == $hms1[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "冠军") {
            if ($v['number'] == $hm1[0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "亚军") {
            if ($v['number'] == $hm1[1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三名") {
            if ($v['number'] == $hm1[2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[5]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四名") {
            if ($v['number'] == $hm1[3]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[6]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五名") {
            if ($v['number'] == $hm1[4]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[7]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六名") {
            if ($v['number'] == $hm1[5]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七名") {
            if ($v['number'] == $hm1[6]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八名") {
            if ($v['number'] == $hm1[7]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第九名") {
            if ($v['number'] == $hm1[8]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[8])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[8])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第十名") {
            if ($v['number'] == $hm1[9]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[9])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[9])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }

    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_bjpk";
    $mysql->query($sql);

    //将北京PK结果表状态修改为正常
    $sql = "update lottery_result_bjpk set state='1' WHERE state='0' AND qishu=$qishu_bjpk";
    $mysql->query($sql);

}

//存在排列3最新一期未结算
if (!empty($arr['P3'])) {//排列3
    $qishu_p3 = $arr['P3']['qishu'];
    $hm2[] = $arr['P3']['ball_1'];
    $hm2[] = $arr['P3']['ball_2'];
    $hm2[] = $arr['P3']['ball_3'];
    $hms2[] = f3D_Auto($hm2, 1);
    $hms2[] = f3D_Auto($hm2, 2);
    $hms2[] = f3D_Auto($hm2, 3);
    $hms2[] = f3D_Auto($hm2, 4);
    $hms2[] = f3D_Auto($hm2, 5);
    $hms2[] = f3D_Auto($hm2, 6);

    //var_dump($hm2);
    //var_dump($hms2);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_p3 AND Gtype='P3') AND status=0";
    $res2 = $mysql->getRows($sql);
    //var_dump($res2);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res2 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if ($v['number'] == $hm2[0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if ($v['number'] == $hm2[1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if ($v['number'] == $hm2[2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms2[1], $hms2[2], $hms2[3]))) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms2['4']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms2['5']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_p3";
    $mysql->query($sql);

    //将排列3结果表状态修改为正常
    $sql = "update lottery_result_p3 set state='1' WHERE state='0' AND qishu=$qishu_p3";
    $mysql->query($sql);
}

//存在福彩3D最新一期未结算
if (!empty($arr['D3'])) {//福彩3D
    $qishu_d3 = $arr['D3']['qishu'];
    $hm3[] = $arr['D3']['ball_1'];
    $hm3[] = $arr['D3']['ball_2'];
    $hm3[] = $arr['D3']['ball_3'];
    $hms3[] = f3D_Auto($hm3, 1);
    $hms3[] = f3D_Auto($hm3, 2);
    $hms3[] = f3D_Auto($hm3, 3);
    $hms3[] = f3D_Auto($hm3, 4);
    $hms3[] = f3D_Auto($hm3, 5);
    $hms3[] = f3D_Auto($hm3, 6);

    //var_dump($hm3);
    //var_dump($hms3);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_d3 AND Gtype='D3') AND status=0";
    $res3 = $mysql->getRows($sql);
    //var_dump($res3);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res3 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if ($v['number'] == $hm3[0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if ($v['number'] == $hm3[1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if ($v['number'] == $hm3[2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms3[1], $hms3[2], $hms3[3]))) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms3['4']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms3['5']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_d3";
    $mysql->query($sql);

    //将福彩3D结果表状态修改为正常
    $sql = "update lottery_result_d3 set state='1' WHERE state='0' AND qishu=$qishu_d3";
    $mysql->query($sql);


}

//存在广东11选5最新一期未结算
if (!empty($arr['GD11'])) {//广东11选5
    $qishu_gd11 = $arr['GD11']['qishu'];
    $hm4[] = $arr['GD11']['ball_1'];
    $hm4[] = $arr['GD11']['ball_2'];
    $hm4[] = $arr['GD11']['ball_3'];
    $hm4[] = $arr['GD11']['ball_4'];
    $hm4[] = $arr['GD11']['ball_5'];
    $hms4[] = gd11x5_Auto($hm4, 1);
    $hms4[] = gd11x5_Auto($hm4, 2);
    $hms4[] = gd11x5_Auto($hm4, 3);
    $hms4[] = gd11x5_Auto($hm4, 4);
    $hms4[] = gd11x5_Auto($hm4, 5);
    $hms4[] = gd11x5_Auto($hm4, 6);
    $hms4[] = gd11x5_Auto($hm4, 7);

    //var_dump($hm4);
    //var_dump($hms4);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gd11 AND Gtype='GD11') AND status=0";
    $res4 = $mysql->getRows($sql);
    //var_dump($res4);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res4 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[0]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms4[1], $hms4[2], $hms4[3]))) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms4[4]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms4[5]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms4[6]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gd11";
    $mysql->query($sql);

    //将广东11选5结果表状态修改为正常
    $sql = "update lottery_result_gd11 set state='1' WHERE state='0' AND qishu=$qishu_gd11";
    $mysql->query($sql);
}

//存在天津时时彩最新一期未结算
if (!empty($arr['TJ'])) {//天津时时彩
    //对开奖结果进行换算规则
    $niuniu1 = b5_niuniu($arr['TJ']['ball_1'], $arr['TJ']['ball_2'], $arr['TJ']['ball_3'], $arr['TJ']['ball_4'], $arr['TJ']['ball_5']);
    $qishu_tj = $arr['TJ']['qishu'];
    //$hm存放球号
    $hm5[] = $arr['TJ']['ball_1'];//第一个球
    $hm5[] = $arr['TJ']['ball_2'];//第二个球
    $hm5[] = $arr['TJ']['ball_3'];//第三个球
    $hm5[] = $arr['TJ']['ball_4'];//第四个球
    $hm5[] = $arr['TJ']['ball_5'];//第五个球
    //$hms存放规则
    $hms5['zhs'][] = Ssc_Auto($hm5, 1);//算总和
    $hms5['zh'][] = Ssc_Auto($hm5, 2);//算总和大小
    $hms5['zh'][] = Ssc_Auto($hm5, 3);//算总和单双
    $hms5['zh'][] = Ssc_Auto($hm5, 4);//算龙虎和
    $hms5['three'][] = Ssc_Auto($hm5, 5);//算前三
    $hms5['three'][] = Ssc_Auto($hm5, 6);//算中三
    $hms5['three'][] = Ssc_Auto($hm5, 7);//算后三
    $hms5['niuniu'][] = $niuniu1;//牛牛
    $hms5['niuniu'][] = b5_niuds($niuniu1);//牛大
    $hms5['niuniu'][] = b5_niudx($niuniu1);//牛小


    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_tj AND Gtype='TJ') AND status=0";
    $res5 = $mysql->getRows($sql);

    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();
    foreach ($res5 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[0]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], $hms5['zh'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms5['three'][0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms5['three'][1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms5['three'][2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "牛牛") {
            if (in_array($v['number'], $hms5['niuniu'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_tj";
    $mysql->query($sql);

    //将时时彩结果表状态修改为正常
    $sql = "update lottery_result_tj set state='1' WHERE state='0' AND qishu=$qishu_tj";
    $mysql->query($sql);
}

//存在广东快乐十分最新一期未结算
if (!empty($arr['GDSF'])) {
    //对开奖结果进行换算规则
    $qishu_gdsf = $arr['GDSF']['qishu'];
    //$hm存放球号
    $hm6[] = $arr['GDSF']['ball_1'];//第一个球
    $hm6[] = $arr['GDSF']['ball_2'];//第二个球
    $hm6[] = $arr['GDSF']['ball_3'];//第三个球
    $hm6[] = $arr['GDSF']['ball_4'];//第四个球
    $hm6[] = $arr['GDSF']['ball_5'];//第五个球
    $hm6[] = $arr['GDSF']['ball_6'];//第六个球
    $hm6[] = $arr['GDSF']['ball_7'];//第七个球
    $hm6[] = $arr['GDSF']['ball_8'];//第八个球
    //$hms存放规则
    $hms6['zhs'][] = G10_Auto($hm6, 1);//算总和
    $hms6['zh'][] = G10_Auto($hm6, 2);//算总和大小
    $hms6['zh'][] = G10_Auto($hm6, 3);//算总和单双
    $hms6['zh'][] = G10_Auto($hm6, 4);//算总和尾大尾小
    $hms6['zh'][] = G10_Auto($hm6, 5);//算龙虎
    $sql = "select order_num,order_sub_num,quick_type,number,win,status,bet_money,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gdsf AND Gtype='GDSF') AND status=0";
    $res6 = $mysql->getRows($sql);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();
    foreach ($res6 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[0]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[5]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[6]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[7]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm6[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎") {
            if ($hms6['zhs'][0] == 84 && in_array($v['number'], $zhdx)) {//判断如果开奖结果为84则表示结果为和 为平局，退还下注金额

                echo "hello<br>";
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $hms6['zh'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }

        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));
    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gdsf";
    $mysql->query($sql);

    //将时时彩结果表状态修改为正常
    $sql = "update lottery_result_gdsf set state='1' WHERE state='0' AND qishu=$qishu_gdsf";
    $mysql->query($sql);


}

//存在天津快乐十分最新一期未结算
if (!empty($arr['TJSF'])) {
    //对开奖结果进行换算规则
    $qishu_tjsf = $arr['TJSF']['qishu'];
    //$qishu_tjsf =20180108050;
    //$hm存放球号
    $hm7[] = $arr['TJSF']['ball_1'];//第一个球
    $hm7[] = $arr['TJSF']['ball_2'];//第二个球
    $hm7[] = $arr['TJSF']['ball_3'];//第三个球
    $hm7[] = $arr['TJSF']['ball_4'];//第四个球
    $hm7[] = $arr['TJSF']['ball_5'];//第五个球
    $hm7[] = $arr['TJSF']['ball_6'];//第六个球
    $hm7[] = $arr['TJSF']['ball_7'];//第七个球
    $hm7[] = $arr['TJSF']['ball_8'];//第八个球
    //$hms存放规则
    $hms7['zhs'][] = G10_Auto($hm7, 1);//算总和
    $hms7['zh'][] = G10_Auto($hm7, 2);//算总和大小
    $hms7['zh'][] = G10_Auto($hm7, 3);//算总和单双
    $hms7['zh'][] = G10_Auto($hm7, 4);//算总和尾大尾小
    $hms7['zh'][] = G10_Auto($hm7, 5);//算龙虎
    $sql = "select order_num,order_sub_num,quick_type,number,win,status,bet_money,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_tjsf AND Gtype='TJSF') AND status=0";
    $res7 = $mysql->getRows($sql);

    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();
    foreach ($res7 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[0]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[3])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[4])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[5]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[5])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[6]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[6])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[7]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hsds)) {
                if ($v['number'] == G10_HsDs($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wsdx)) {
                if ($v['number'] == G10_WsDx($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $dnxb)) {
                if ($v['number'] == G10_Fw($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[7])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎") {
            if ($hms7['zhs'][0] == 84 && in_array($v['number'], $zhdx)) {//判断如果开奖结果为84则表示结果为和 为平局，退还下注金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $hms7['zh'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }

        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));
    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_tjsf";
    $mysql->query($sql);

    //将时时彩结果表状态修改为正常
    $sql = "update lottery_result_tjsf set state='1' WHERE state='0' AND qishu=$qishu_tjsf";
    $mysql->query($sql);


}

//存在北京快乐八最新一期未结算
if (!empty($arr['BJKN'])) {
    $qishu_bjkn = $arr['BJKN']['qishu'];
//    $qishu_bjkn = 867282;
    $hm8[] = $arr['BJKN']['ball_1'];//第一个球
    $hm8[] = $arr['BJKN']['ball_2'];//第二个球
    $hm8[] = $arr['BJKN']['ball_3'];//第三个球
    $hm8[] = $arr['BJKN']['ball_4'];//第四个球
    $hm8[] = $arr['BJKN']['ball_5'];//第五个球
    $hm8[] = $arr['BJKN']['ball_6'];//第六个球
    $hm8[] = $arr['BJKN']['ball_7'];//第七个球
    $hm8[] = $arr['BJKN']['ball_8'];//第八个球
    $hm8[] = $arr['BJKN']['ball_9'];//第九个球
    $hm8[] = $arr['BJKN']['ball_10'];//第十个球
    $hm8[] = $arr['BJKN']['ball_11'];//第十一个球
    $hm8[] = $arr['BJKN']['ball_12'];//第十二个球
    $hm8[] = $arr['BJKN']['ball_13'];//第十三个球
    $hm8[] = $arr['BJKN']['ball_14'];//第十四个球
    $hm8[] = $arr['BJKN']['ball_15'];//第十五个球
    $hm8[] = $arr['BJKN']['ball_16'];//第十六个球
    $hm8[] = $arr['BJKN']['ball_17'];//第十七个球
    $hm8[] = $arr['BJKN']['ball_18'];//第十八个球
    $hm8[] = $arr['BJKN']['ball_19'];//第十九球
    $hm8[] = $arr['BJKN']['ball_20'];//第二十个球
    //计算开奖结果
    $hms8['hz'][] = Kl8_Auto_zh($hm8, 1);//计算总和值
    $hms8['hz'][] = Kl8_Auto_zh($hm8, 2);//计算总和值大小 810
    $hms8['hz'][] = Kl8_Auto_zh($hm8, 3);//计算总和值单双
    $hms8['szx'] = Kl8_Auto_zh($hm8, 4);//计算上中下
    $hms8['joh'] = Kl8_Auto_zh($hm8, 5);//计算奇偶和

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,bet_money,bet_rate,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number= $qishu_bjkn AND Gtype='BJKN') AND status=0";
    $res8 = $mysql->getRows($sql);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();
    if (!empty($res8)) {
        foreach ($res8 as $k => $v) {
            $arr1[] = $v['order_sub_num'];
            if ($v['quick_type'] == "选一") {
                if (in_array($v['number'], $hm8)) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }

            if ($v['quick_type'] == "选二") {
                $vnum = explode(',', $v['number']);
                $betr = explode(',', $v['bet_rate']);
                $i = 0;
                foreach ($vnum as $k => $v) {
                    if (in_array($v, $hm8)) {
                        $i++;
                    }
                }
                if ($i == 2) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if ($v['quick_type'] == "选三") {
                $vnum = explode(',', $v['number']);
                $betr = explode(',', $v['bet_rate']);

                $i = 0;
                foreach ($vnum as $k => $v) {
                    if (in_array($v, $hm8)) {
                        $i++;
                    }
                }
                if ($i == 3) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                } elseif ($i == 2) {
                    $array = array("win" => $v['bet_money'] * $betr[1], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if ($v['quick_type'] == "选四") {
                $vnum = explode(',', $v['number']);
                $betr = explode(',', $v['bet_rate']);

                $i = 0;
                foreach ($vnum as $k => $v) {
                    if (in_array($v, $hm8)) {
                        $i++;
                    }
                }
                if ($i == 4) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                } elseif ($i == 3) {
                    $array = array("win" => $v['bet_money'] * $betr[1], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                } elseif ($i == 2) {
                    $array = array("win" => $v['bet_money'] * $betr[2], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if ($v['quick_type'] == "选五") {
                $vnum = explode(',', $v['number']);
                $betr = explode(',', $v['bet_rate']);

                $i = 0;
                foreach ($vnum as $k => $v) {
                    if (in_array($v, $hm8)) {
                        $i++;
                    }
                }
                if ($i == 5) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                } elseif ($i == 4) {
                    $array = array("win" => $v['bet_money'] * $betr[1], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                } elseif ($i == 3) {
                    $array = array("win" => $v['bet_money'] * $betr[2], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if ($v['quick_type'] == "奇偶和") {

                if ($v['number'] == $hms8['joh']) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if ($v['quick_type'] == "上中下") {

                if (in_array($v['number'], $hms8)) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }
            if ($v['quick_type'] == "和值") {
                if (in_array($v['number'], $hms8['hz'])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }

            }

        }
        //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
        $arr2 = implode(',', array_unique($arr1));
        //判断中奖数组存在且不为空的时候
        if (isset($zjresultall) && !empty($zjresultall)) {
            foreach ($zjresultall as $k => $v) {
                $win = 0.0;
                $set = array('is_win' => $v['is_win'], 'status' => 1);
                $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
                $win = (float)$v['win'];
                $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
                $mysql->query($sql_money);
            }
        }
        //将子订单表中状态未结算修改为正常
        $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
        $mysql->query($sql);

        //将总订单表中状态未结算修改为正常
        $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_bjkn";
        $mysql->query($sql);

        //将时时彩结果表状态修改为正常
        $sql = "update lottery_result_bjkn set state='1' WHERE state='0' AND qishu=$qishu_bjkn";
        $mysql->query($sql);

    }


}

//存在广西十分彩最新一期未结算
if (!empty($arr['GXSF'])) {

    //对开奖结果进行换算规则
    $qishu_gxsf = $arr['GXSF']['qishu'];
    //$qishu_gxsf = 201800833;
    //$hm存放球号
    $hm9[] = $arr['GXSF']['ball_1'];//第一个球
    $hm9[] = $arr['GXSF']['ball_2'];//第二个球
    $hm9[] = $arr['GXSF']['ball_3'];//第三个球
    $hm9[] = $arr['GXSF']['ball_4'];//第四个球
    $hm9[] = $arr['GXSF']['ball_5'];//第五个球
    //$hms存放规则
    $hms9['zhs'][] = gxsf_Auto($hm9, 1);//算总和
    $hms9['zh'][] = gxsf_Auto($hm9, 2);//算总和大小
    $hms9['zh'][] = gxsf_Auto($hm9, 3);//算总和单双
    $hms9['zh'][] = gxsf_Auto($hm9, 4);//算龙虎和
    $hms9['three'][] = gxsf_Auto($hm9, 5);//算前三
    $hms9['three'][] = gxsf_Auto($hm9, 6);//算中三
    $hms9['three'][] = gxsf_Auto($hm9, 7);//算后三


    //var_dump($hms);
    //var_dump($hm);

    $sql = "select order_num,order_sub_num,quick_type,bet_money,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gxsf AND Gtype='GXSF') AND status=0";
    $res = $mysql->getRows($sql);
    //var_dump($res);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm9[0]) {
                    $array = array("win" => $v['win'], "is_win" => 1, "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if ($hms9['zhs'][0] == 21 && (in_array($v['number'], $dx) || in_array($v['number'], $ds))) {//如果开奖结果等于21 且在大小数组中里 则退还金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);

            } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm9[0])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm9[0])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }

        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm9[1]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if ($hms9['zhs'][0] == 21 && (in_array($v['number'], $dx) || in_array($v['number'], $ds))) {//如果开奖结果等于21 且在大小数组中里 则退还金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);

            } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm9[1])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm9[1])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm9[2]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if ($hms9['zhs'][0] == 21 && (in_array($v['number'], $dx) || in_array($v['number'], $ds))) {//如果开奖结果等于21 且在大小数组中里 则退还金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);

            } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm9[2])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm9[2])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm9[3]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if ($hms9['zhs'][0] == 21 && (in_array($v['number'], $dx) || in_array($v['number'], $ds))) {//如果开奖结果等于21 且在大小数组中里 则退还金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);

            } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm9[3])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm9[3])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm9[4]) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                    array_push($zjresultall, $array);
                }
            }
            if ($hms9['zhs'][0] == 21 && (in_array($v['number'], $dx) || in_array($v['number'], $ds))) {//如果开奖结果等于21 且在大小数组中里 则退还金额
                $array = array("win" => $v['bet_money'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 2);
                array_push($zjresultall, $array);

            } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm9[4])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm9[4])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], $hms9['zh'])) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms9['three'][0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms9['three'][1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms9['three'][2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num'], "is_win" => 1);
                array_push($zjresultall, $array);
            }
        }
    }
//函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));
//判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
//将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

//将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gxsf";
    $mysql->query($sql);

//将时时彩结果表状态修改为正常
    $sql = "update lottery_result_gxsf set state='1' WHERE state='0' AND qishu=$qishu_gxsf";
    $mysql->query($sql);

}

//存在上海时时乐  江苏快三
if (!empty($arr['T3'])) {//福彩3D
    $qishu_t3 = $arr['T3']['qishu'];
    $hm10[] = $arr['T3']['ball_1'];
    $hm10[] = $arr['T3']['ball_2'];
    $hm10[] = $arr['T3']['ball_3'];
    $hms10[] = f3D_Auto($hm10, 1);//总和大小
    $hms10[] = f3D_Auto($hm10, 2);
    $hms10[] = f3D_Auto($hm10, 3);
    $hms10[] = f3D_Auto($hm10, 4);
    $hms10[] = f3D_Auto($hm10, 5);
    $hms10[] = f3D_Auto($hm10, 6);

    //var_dump($hm3);
    //var_dump($hms3);

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_d3 AND Gtype='D3') AND status=0";
    $res3 = $mysql->getRows($sql);
    //var_dump($res3);
    //定义数组存放对应彩种的子订单
    $arr1 = array();
    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res3 as $k => $v) {
        $arr1[] = $v['order_sub_num'];
        if ($v['quick_type'] == "第一球") {
            if ($v['number'] == $hm3[0]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[0])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if ($v['number'] == $hm3[1]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[1])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if ($v['number'] == $hm3[2]) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            } elseif (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[2])) {
                    $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms3[1], $hms3[2], $hms3[3]))) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms3['4']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms3['5']) {
                $array = array("win" => $v['win'], "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }
    //函数移除数组中的重复的值，并返回结果数组,再拼接成字符串
    $arr2 = implode(',', array_unique($arr1));

    //判断中奖数组存在且不为空的时候
    if (isset($zjresultall) && !empty($zjresultall)) {
        var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {
            $win = 0.0;
            $set = array('is_win' => 1, 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = (float)$v['win'];

            $sql_money = "update user_list set money=money+$win WHERE user_id=(SELECT user_id FROM order_lottery WHERE order_num=$v[order_num])";
            $mysql->query($sql_money);
        }
    }
    //将子订单表中状态未结算修改为正常
    $sql = "update order_lottery_sub set status='1',is_win='0' WHERE status='0'AND order_sub_num IN ($arr2)";
    $mysql->query($sql);

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_d3";
    $mysql->query($sql);

    //将福彩3D结果表状态修改为正常
    $sql = "update lottery_result_d3 set state='1' WHERE state='0' AND qishu=$qishu_d3";
    $mysql->query($sql);


}


